package com.tanhua.admin.controller;

import com.tanhua.admin.service.DashBoardService;
import com.tanhua.model.vo.UserStatisticsVo;
import com.tanhua.model.vo.YearStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/dashboard")
public class DashBoardController {

    @Autowired
    private DashBoardService dashBoardService;

    //摘要统计
    @GetMapping("/summary")
    public ResponseEntity summaryInfo() {
        UserStatisticsVo usv = dashBoardService.summaryInfo();
        return ResponseEntity.ok(usv);
    }

    //次日留存统计
    @GetMapping("/users")
    public ResponseEntity getStatistics(@RequestParam(value = "sd") Long sd,
                                        @RequestParam(value = "ed") Long ed,
                                        @RequestParam(value = "type") Integer type) {
        YearStatisticsVo ysv = dashBoardService.getStatistics(sd, ed, type);
        return ResponseEntity.ok(ysv);
    }
}
